#include "shuttlebottomlinedialog.h"
#include "ui_shuttlebottomlinedialog.h"

shuttlebottomlineDialog::shuttlebottomlineDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::shuttlebottomlineDialog)
{
    ui->setupUi(this);
    setWindowFlags (Qt::Window | Qt::FramelessWindowHint);
    setWindowModality(Qt::ApplicationModal);

    initControlStyle();
}

shuttlebottomlineDialog::~shuttlebottomlineDialog()
{
    delete ui;
}

void shuttlebottomlineDialog::on_buttonOk_clicked()
{
    done(0);
}

void shuttlebottomlineDialog::on_buttonCancel_clicked()
{
    done(0);
}


void shuttlebottomlineDialog::initControlStyle()
{

    double factoryX = getFactoryX();
    double factoryY = getFactoryY();

    SetStyle setControlStyle;
    setControlStyle.setUiName(this->objectName());


    //背景图
    QString frameBackImgPath = setControlStyle.getSharedStyleSheet();
    ui->frameBack->setStyleSheet(frameBackImgPath);
    //    ui->frameShuttleline->setStyleSheet(transparentStyle());
    //    ui->frameShuttleline->setStyleSheet(setControlStyle.getStyleSheet(this->objectName()));
    ui->frameShuttleline->setGeometry(0,0,1920,900);



    //范围  只写了1920*1080的
    this->resize(GLB_SCR_WIGHT*factoryX,GLB_SCR_HEIGHT*factoryY);
    this->move((GLB_SCR_WIGHT*factoryX-this->width())/2+g_mainWidgetPos.x(),(GLB_SCR_HEIGHT*factoryY-this->height())/2+g_mainWidgetPos.y());
    ui->frameBack->setGeometry(0*factoryX, 0*factoryY, GLB_SCR_WIGHT*factoryX, GLB_SCR_HEIGHT*factoryY);
    ui->framePageBtn->setGeometry(0*factoryX,(GLB_SCR_HEIGHT-GLB_LBUT_HEIGHT-GLB_EDGE_WIGHT)*factoryY,GLB_SCR_WIGHT*factoryX,GLB_LBUT_HEIGHT*factoryY);
    ui->buttonOk->setGeometry((GLB_SCR_WIGHT-(GLB_EDGE_WIGHT+GLB_BAS_WIGHT*1+GLB_LBUT_WIGHT*2))*factoryX,0*factoryY,GLB_LBUT_WIGHT*factoryX,GLB_LBUT_HEIGHT*factoryY);
    ui->buttonCancel->setGeometry((GLB_SCR_WIGHT-(GLB_EDGE_WIGHT+GLB_BAS_WIGHT*0+GLB_LBUT_WIGHT*1))*factoryX,0*factoryY,GLB_LBUT_WIGHT*factoryX,GLB_LBUT_HEIGHT*factoryY);

    ui->buttonOk->setStyleSheet(confirmIconStyle());
    ui->buttonOk->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonOk->objectName()),12);

    ui->buttonCancel->setStyleSheet(confirmIconStyle());
    ui->buttonCancel->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->buttonCancel->objectName()),12);

    ui->ShuttleButton->setGeometry(200,400,120,120);
    ui->ShuttleButtonlabel->setGeometry(190,550,150,120);
    ui->ShuttleButton->setStyleSheet(confirmIconStyle());
    ui->ShuttleButton->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->ShuttleButton->objectName()),12);

    ui->ShuttleButton_2->setGeometry(400,400,120,120);
    ui->ShuttleButtonlabel_2->setGeometry(390,550,150,120);
    ui->ShuttleButton_2->setStyleSheet(confirmIconStyle());
    ui->ShuttleButton_2->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->ShuttleButton->objectName()),12);

    ui->ShuttleButton_3->setGeometry(600,400,120,120);
    ui->ShuttleButtonlabel_3->setGeometry(590,550,150,120);
    ui->ShuttleButton_3->setStyleSheet(confirmIconStyle());
    ui->ShuttleButton_3->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->ShuttleButton->objectName()),12);

    ui->ShuttleButton_4->setGeometry(800,400,120,120);
    ui->ShuttleButtonlabel_4->setGeometry(790,550,150,120);
    ui->ShuttleButton_4->setStyleSheet(confirmIconStyle());
    ui->ShuttleButton_4->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->ShuttleButton->objectName()),12);

    ui->ShuttleButton_5->setGeometry(1000,400,120,120);
    ui->ShuttleButtonlabel_5->setGeometry(990,550,150,120);
    ui->ShuttleButton_5->setStyleSheet(confirmIconStyle());
    ui->ShuttleButton_5->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->ShuttleButton->objectName()),12);

    ui->ShuttleButton_6->setGeometry(1200,400,120,120);
    ui->ShuttleButtonlabel_6->setGeometry(1190,550,150,120);
    ui->ShuttleButton_6->setStyleSheet(confirmIconStyle());
    ui->ShuttleButton_6->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->ShuttleButton->objectName()),12);

    ui->ShuttleButton_7->setGeometry(1400,400,120,120);
    ui->ShuttleButtonlabel_7->setGeometry(1390,550,150,120);
    ui->ShuttleButton_7->setStyleSheet(confirmIconStyle());
    ui->ShuttleButton_7->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->ShuttleButton->objectName()),12);


    ui->ShuttleButton_8->setGeometry(1600,400,120,120);
    ui->ShuttleButtonlabel_8->setGeometry(1590,550,150,120);
    ui->ShuttleButton_8->setStyleSheet(confirmIconStyle());
    ui->ShuttleButton_8->setTopImage(setControlStyle.getSharedTopStyleSheet(ui->ShuttleButton->objectName()),12);

    ui->ShuttleButtonlabel->setStyleSheet(stateTextColour());
    ui->ShuttleButtonlabel->setWordWrap(true);
    ui->ShuttleButtonlabel->setAlignment((Qt::AlignTop|Qt::AlignHCenter));
    ui->ShuttleButtonlabel->setFont(fontSize_M());

    ui->ShuttleButtonlabel_2->setStyleSheet(stateTextColour());
    ui->ShuttleButtonlabel_2->setWordWrap(true);
    ui->ShuttleButtonlabel_2->setAlignment((Qt::AlignTop|Qt::AlignHCenter));
    ui->ShuttleButtonlabel_2->setFont(fontSize_M());

    ui->ShuttleButtonlabel_3->setStyleSheet(stateTextColour());
    ui->ShuttleButtonlabel_3->setWordWrap(true);
    ui->ShuttleButtonlabel_3->setAlignment((Qt::AlignTop|Qt::AlignHCenter));
    ui->ShuttleButtonlabel_3->setFont(fontSize_M());

    ui->ShuttleButtonlabel_4->setStyleSheet(stateTextColour());
    ui->ShuttleButtonlabel_4->setWordWrap(true);
    ui->ShuttleButtonlabel_4->setAlignment((Qt::AlignTop|Qt::AlignHCenter));
    ui->ShuttleButtonlabel_4->setFont(fontSize_M());

    ui->ShuttleButtonlabel_5->setStyleSheet(stateTextColour());
    ui->ShuttleButtonlabel_5->setWordWrap(true);
    ui->ShuttleButtonlabel_5->setAlignment((Qt::AlignTop|Qt::AlignHCenter));
    ui->ShuttleButtonlabel_5->setFont(fontSize_M());

    ui->ShuttleButtonlabel_6->setStyleSheet(stateTextColour());
    ui->ShuttleButtonlabel_6->setWordWrap(true);
    ui->ShuttleButtonlabel_6->setAlignment((Qt::AlignTop|Qt::AlignHCenter));
    ui->ShuttleButtonlabel_6->setFont(fontSize_M());

    ui->ShuttleButtonlabel_7->setStyleSheet(stateTextColour());
    ui->ShuttleButtonlabel_7->setWordWrap(true);
    ui->ShuttleButtonlabel_7->setAlignment((Qt::AlignTop|Qt::AlignHCenter));
    ui->ShuttleButtonlabel_7->setFont(fontSize_M());

    ui->ShuttleButtonlabel_8->setStyleSheet(stateTextColour());
    ui->ShuttleButtonlabel_8->setWordWrap(true);
    ui->ShuttleButtonlabel_8->setAlignment((Qt::AlignTop|Qt::AlignHCenter));
    ui->ShuttleButtonlabel_8->setFont(fontSize_M());


}

void shuttlebottomlineDialog::showShuttlenumber(int remainShuttle , int NowBottom)
{
    ui->frameShuttleline->show();
    ui->framePageBtn->show();
    if(remainShuttle == 1)
    {
        ui->ShuttleButton->setEnabled(false);
        ui->ShuttleButton_2->setEnabled(false);
        ui->ShuttleButton_3->setEnabled(false);
        ui->ShuttleButton_4->setEnabled(false);
        ui->ShuttleButton_5->setEnabled(false);
        ui->ShuttleButton_6->setEnabled(false);
        ui->ShuttleButton_7->setEnabled(false);

        ui->ShuttleButtonlabel->setText(tr("Remaining quantity:") + tr("finally"));//已用完
        ui->ShuttleButtonlabel_2->setText(tr("Remaining quantity:") + tr("finally"));//已用完
        ui->ShuttleButtonlabel_3->setText(tr("Remaining quantity:") + tr("finally"));//已用完
        ui->ShuttleButtonlabel_4->setText(tr("Remaining quantity:") + tr("finally"));//已用完
        ui->ShuttleButtonlabel_5->setText(tr("Remaining quantity:") + tr("finally"));//已用完
        ui->ShuttleButtonlabel_6->setText(tr("Remaining quantity:") + tr("finally"));//已用完
        ui->ShuttleButtonlabel_7->setText(tr("Remaining quantity:") + tr("finally"));//已用完
        ui->ShuttleButtonlabel_8->setText(tr("Remaining quantity:") + " " + QString::number(NowBottom) +"%");//当前梭芯底线剩余量
    }
    else if(remainShuttle == 2)
    {
        ui->ShuttleButton->setEnabled(false);
        ui->ShuttleButton_2->setEnabled(false);
        ui->ShuttleButton_3->setEnabled(false);
        ui->ShuttleButton_4->setEnabled(false);
        ui->ShuttleButton_5->setEnabled(false);
        ui->ShuttleButton_6->setEnabled(false);

        ui->ShuttleButtonlabel->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_2->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_3->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_4->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_5->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_6->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_7->setText(tr("Remaining quantity:") + " " + QString::number(NowBottom) +"%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_8->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
    }
    else if(remainShuttle == 3)
    {
        ui->ShuttleButton->setEnabled(false);
        ui->ShuttleButton_2->setEnabled(false);
        ui->ShuttleButton_3->setEnabled(false);
        ui->ShuttleButton_4->setEnabled(false);
        ui->ShuttleButton_5->setEnabled(false);
        ui->ShuttleButtonlabel->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_2->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_3->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_4->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_5->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_6->setText(tr("Remaining quantity:") + " " + QString::number(NowBottom) +"%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_7->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_8->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
    }
    else if(remainShuttle == 4)
    {
        ui->ShuttleButton->setEnabled(false);
        ui->ShuttleButton_2->setEnabled(false);
        ui->ShuttleButton_3->setEnabled(false);
        ui->ShuttleButton_4->setEnabled(false);
        ui->ShuttleButtonlabel->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_2->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_3->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_4->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_5->setText(tr("Remaining quantity:") + " " + QString::number(NowBottom) +"%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_6->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_7->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_8->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
    }
    else if(remainShuttle == 5)
    {
        ui->ShuttleButton->setEnabled(false);
        ui->ShuttleButton_2->setEnabled(false);
        ui->ShuttleButton_3->setEnabled(false);
        ui->ShuttleButtonlabel->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_2->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_3->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_4->setText(tr("Remaining quantity:") + " " + QString::number(NowBottom) +"%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_5->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_6->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_7->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_8->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
    }
    else if(remainShuttle == 6)
    {
        ui->ShuttleButton->setEnabled(false);
        ui->ShuttleButton_2->setEnabled(false);
        ui->ShuttleButtonlabel->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_2->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_3->setText(tr("Remaining quantity:") + " " + QString::number(NowBottom) +"%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_4->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_5->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_6->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_7->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_8->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
    }
    else if(remainShuttle == 7)
    {
        ui->ShuttleButton->setEnabled(false);
        ui->ShuttleButtonlabel->setText(tr("Remaining quantity:") + " " + tr("finally"));//已用完
        ui->ShuttleButtonlabel_2->setText(tr("Remaining quantity:") + " " + QString::number(NowBottom) +"%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_3->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_4->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_5->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_6->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_7->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_8->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
    }
    else if(remainShuttle == 8)
    {
        ui->ShuttleButtonlabel->setText(tr("Remaining quantity:") + " " + QString::number(NowBottom) +"%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_2->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_3->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_4->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_5->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_6->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_7->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
        ui->ShuttleButtonlabel_8->setText(tr("Remaining quantity:") + " " + "100%");//当前梭芯底线剩余量
    }
    else if(remainShuttle == 0)
    {
        ui->ShuttleButton->setEnabled(false);
        ui->ShuttleButton_2->setEnabled(false);
        ui->ShuttleButton_3->setEnabled(false);
        ui->ShuttleButton_4->setEnabled(false);
        ui->ShuttleButton_5->setEnabled(false);
        ui->ShuttleButton_6->setEnabled(false);
        ui->ShuttleButton_7->setEnabled(false);
        ui->ShuttleButton_8->setEnabled(false);
    }

}
